package asa;

import AuxComp.*;

public class Program {

	public Program(StatementList statementList, SymbolTable symbolTable) {
		this.statementList = statementList;
		this.symbolTable = symbolTable;
	}

	public void genJava(PWInterface pw, String actorName) {
		//pw.println("import java.util.*;\n");
		if ( symbolTable.getStaticVariableTable().values() != null )
			for (Variable v : symbolTable.getStaticVariableTable().values()) {
				pw.printlnIdent("private Integer " + v.getName() + ";");
			}
		pw.println("");
		pw.printlnIdent("public void act() {");
		pw.add();
		if ( symbolTable.getLocalVariableTable().values() != null )
			for (Variable v : symbolTable.getLocalVariableTable().values()) {
				pw.printlnIdent("Integer " + v.getName() + ";");
			}

		statementList.genJava(pw, new Env());
		pw.sub();
		pw.printlnIdent("}");
	}

	public StatementList getStatementList() {
		return statementList;
	}

	public void setStatementList(StatementList statementList) {
		this.statementList = statementList;
	}

	public SymbolTable getSymbolTable() {
		return symbolTable;
	}

	public void setSymbolTable(SymbolTable symbolTable) {
		this.symbolTable = symbolTable;
	}

	private StatementList statementList;
	private SymbolTable symbolTable;
}